package com.litchi.activity;

import java.util.List;

import com.lib.uil.ToastUtils;
import com.litchi.R;
import com.litchi.bean.Goods;
import com.litchi.utils.Constants;

import android.os.Bundle;
import android.text.TextUtils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.FindListener;

public class SearchActivity extends Activity implements OnClickListener {

	private TextView searchTextView;
	private EditText searchEditView;
	private Context mContext;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search);
		mContext = this;
		initView();

	}

	public void initView() {
		findViewById(R.id.img_back).setOnClickListener(this);
		searchTextView = (TextView) findViewById(R.id.tv_search);
		searchEditView=(EditText)findViewById(R.id.editview_search);
		searchTextView.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.img_back:
			finish();

			break;
		case R.id.tv_search:

			goSearch(searchEditView.getText().toString());
			break;

		default:
			break;
		}
	}

	/**
	 * 
	 * 跳转到商品列表界面
	 */
	public void goSearch(String word) {
		if (!TextUtils.isEmpty(word.trim())) {
			Intent intent = new Intent(mContext, GoodsListActivity.class);
			intent.putExtra(Constants.GOODS_SEARCH_KEY, word);
			startActivity(intent);
		}
	}

}
